package com.forum.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.forum.model.dao.ForumUserDAO;
import com.forum.model.pojo.ForumUser;

@WebServlet("/CheckUserController")
public class CheckUserController extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		String userLogin = request.getParameter("loginName");
		ForumUserDAO userDao = new ForumUserDAO();
		ForumUser user = userDao.getUserByLoginName(userLogin);
		PrintWriter out = response.getWriter();

		if (user == null) {
			out.write("true");
		} else {
			out.write("false");
		}

		out.close();
	}
}
